<?php
        $cate=new \Common\Model\Cate;
        $topCate=$cate->where("pid=0")->get();
/**
 * 检测cart是否存在，初次加载网页返回空
 */
		if(isset($_SESSION['cart']['total_rows'])){
			$data=$_SESSION['cart']['total_rows']==0?null:$_SESSION['cart']['goods'];
		}else{
			$data=null;
		}
        $_SESSION['cart']['total_rows']=isset($_SESSION['cart']['total_rows'])?$_SESSION['cart']['total_rows']:0;
//		P($_SESSION);
?>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>360商城</title>
		<script src="./Public/Home/js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="./Public/Home/js/index.js" type="text/javascript" charset="utf-8"></script>
  		<script type="text/javascript" charset="utf-8" src="Public/Home/js/jquery.leanModal.min.js"></script>
  		<script src="./Public/Home/hdjs/hdjs.min.js" type="text/javascript" charset="utf-8"></script>
		<link rel="stylesheet" type="text/css" href="Public/Home/css/index.css">
		<link rel="stylesheet" type="text/css" href="Public/Home/hdjs/hdjs.css">
		<link rel="stylesheet" type="text/css" href="Public/Home/css/list.css">
<!--		<script >-->
<!--			$(function(){-->
<!--				$(".flatbtn").click(function(){-->
<!--					$(".bj").fadeToggle(100);-->
<!--					$(".div").slideToggle(100);-->
<!--				});-->
<!---->
<!--				$(".bj").click(function(){-->
<!--					$(".div").slideToggle(100);-->
<!--					$(".bj").fadeToggle(100);-->
<!---->
<!--				});-->
<!---->
<!--				$(".zq").click(function(){-->
<!--					var a=$(this).text();-->
<!--					$.ajax({-->
<!--						type:"post",-->
<!--						url:'<?php echo U("index/edl")?>',-->
<!--						data:{cs:a},-->
<!--						dataType:'json',-->
<!--						success:function(db){-->
<!---->
<!--						}-->
<!--					})-->
<!--				});-->
<!---->
<!--				$(".btns").click(function(){-->
<!--					var cs=$(".cs").val();-->
<!---->
<!--					var zq=$(this).text();-->
<!--					alert(zq);-->
<!--					$.ajax({-->
<!--						type:"post",-->
<!--						url:'<?php echo U("index/edl")?>',-->
<!--						data:{cs:cs},-->
<!--						dataType:'json',-->
<!--						success:function(db){-->
<!---->
<!--						}-->
<!--					})-->
<!---->
<!--				})-->
<!---->
<!--			})-->
<!--		</script>-->
		
	</head>
	<style type="text/css" media="screen">
		.bj{
			width:100%;
			height:100%;
			position:fixed;
			z-index:1000;
			background:rgba(0,0,0,0.5);
			display:none;
		}

		.div{
			width:300px;
			height:300px;
			background:#fff;
			position:fixed;
			z-index:1001;
			left:33%;
			top:50px;
			display:none;
		}
	</style>
	<body>
	<!-- <?php $arr=[1,2,3,4,5,6,7,8,9];?> -->
	<div class="div">
		<input type="text" class="cs" name="">
		<input type="text" class="csa" name="">
		<a class="btns title="">提交</a>
	</div>
	<div class="bj"></div>
	<!-- top头部部分开始 -->
		<div id="top">
			<div class="top">
				<div class="right">
					<ul>
						<!-- <li> <a href="javascript:;" title="" class="flatbtn" id="modaltrigger">登录</a></li> -->
						<?php if(!isset($_SESSION['info'])){ ;?>
						<li class="lis"> <a href="<?php echo U('Login/login')?>" title="">登录</a></li>
						<li class="lis"> <a href="<?php echo U('Login/reg')?>" title="">注册</a></li>
						<?php }else{ ?>
						<li class="lis lis1"><a href="" title=""><?php echo $_SESSION['info']['username']?></a>
							<ul>
								<li><a style="color:#24A238;" href="" title=""><?php echo $_SESSION['info']['username']?></a></li>
								<li><a href="">我的订单</a></li>
								<li><a href="">我的喜欢</a></li>
								<li><a href="">收获地址</a></li>
								<li><a href="<?php echo U('Login/out')?>">退出登录</a></li>
							</ul>
						</li>
						<?php }?>
						<li class="lis"> <a href="" title="">我的订单</a></li>
					</ul>
				</div>
			</div>
		</div>
		<!-- logo购物车部分开始 -->
		<div id="search">
			<div class="logo">
				<a href="<?php echo U('Index/index')?>" title=""><img src="./Public/Home/images/logo.png" alt=""></a>
			</div>
			<!-- 搜索框部分开始 -->
			<div class="header_search">
				<div class="form">
					<form action="" method="post" accept-charset="utf-8">
						<input class="input" type="text" name="q" placeholder="360行车记录仪">
						<input class="submit" type="submit" value="">
					</form>
				</div>
				<?php $cart=isset($_GET['c'])?$_GET['c']:''; ?>
				<?php if($cart!='Cart'){?>
                
				<div class="shopcar">
					<div class="gwc">
						<a href="<?php echo U('Cart/index')?>" title=""><i></i>我的购物车<span class="numm">(<?php echo $_SESSION['cart']['total_rows']?>)</span></a>
					</div>
					<div class="gwchtc">
						<?php if(is_null($data)){ ?>
						<a href="javascript:;" title="">您的购物车没有东西<span>(0)</span></a>
						<?php }else{ ?>
						<ul>
							<?php foreach ($data as $k=>$v){?>
							<li class="lf">
								<a href="<?php echo U('Content/index',['gid'=>$v['id']])?>"><img src="<?php echo $v['pic']?>" alt=""></a>
								<span class="much"><?php echo $v['name']?></span>
								<div class="cars">
									￥<span class="picc"><?php echo $v['price']?></span>×<span class="numm"><?php echo $v['num']?></span><strong class="del" sid="<?php echo $k?>">×</strong>
								</div>
							</li>
							<?php }?>
							<li class="jss">
								<div class="cart">
									<p>共计<span class="red red1"><?php echo $_SESSION['cart']['total_rows']?></span>件   共<span class="red red2"><?php echo $_SESSION['cart']['total']?></span>元</p>
								</div>
								<a href="<?php echo U('Cart/index')?>">去购物车</a>
							</li>

						</ul>
						<?php }?>
					</div>
				</div>
				
               <?php }?>
				<div class="hot">
				<a href="">智能出行伴侣</a><a href="">智能出行伴侣</a><a href="">智能出行伴侣</a>
				</div>
			</div>

			<script>
				$(function () {
					//异步删除购物车中的商品
					$(".del").click(function () {
						var sid=$(this).attr('sid');
						$.ajax({
							type:'post',
							url:'<?php echo U("Cart/del")?>',
							data:{c:sid},
							dataType:'json',
							success:function (e) {
								var a="("+e.num+")";
								var b='<a href="javascript:;" title="">您的购物车没有东西<span>(0)</span></a>';
								if(e.num==0){
									$(".gwchtc").html(b);
								}else{
									$(".red1").html(e.num);
								}

								$(".numm").html(a);
								$(".red2").html(e.pri);
							}

						});
						$(this).parents('.lf').remove();
					});
				})
			</script>
			
		</div>
		<!-- top购物车部分结束 -->
		<!-- top分类部分开始 -->
		<div id="cate">	
			<div id="top_cate">
			<div class="cate">
				<a href=""> 全部智能酷品</a>
			</div>
			<ul>
				<?php foreach ($topCate as $v){?>
				<li><a href="<?php echo U('List/index',['cid'=>$v['cid']])?>" title=""><?php echo $v['cname']?></a></li>
				<?php }?>
			</ul>
			</div>
		</div>
